#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 55;
int n, c, f[2][N][N], a[N], b[N];

int sum[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("CppTest.in", "r", stdin);
  freopen("CppTest.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &c);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    sum[i] = sum[i - 1] + b[i];
  }
  memset(f, 0x3f, sizeof(f));
  f[0][c][c] = f[1][c][c] = 0;
  for (int len = 2; len <= n; ++len) {
    for (int l = 1; l <= n - len + 1; ++l) {
      int r = l + len - 1;
      f[0][l][r] =
          std::min(f[0][l + 1][r] + (a[l + 1] - a[l]) * (sum[n] - sum[r] + sum[l]),
                   f[1][l + 1][r] + (a[r] - a[l]) * (sum[n] - sum[r] + sum[l]));
      f[1][l][r] = std::min(
          f[1][l][r - 1] + (a[r] - a[r - 1]) * (sum[n] - sum[r - 1] + sum[l - 1]),
          f[0][l][r - 1] + (a[r] - a[l]) * (sum[n] - sum[r - 1] + sum[l - 1]));
    }
  }
  printf("%d", std::min(f[0][1][n], f[1][1][n]));
  return 0;
}